import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

export const layoutChildren: Array<RouteRecordRaw> = [{
  path: '/',
  name: 'home',
  meta: {
    title: '首页'
  },
  component: () => import(/* webpackChunkName: "home" */ '@/views/home/index.vue'),
}, {
  path: '/select/car',
  name: 'selectCar',
  meta: {
    title: '选车'
  },
  component: () => import(/* webpackChunkName: "selectCar" */ '@/views/selectCar/index.vue')
}, {
  path: '/little/vedio',
  name: 'littleVedio',
  meta: {
    title: '小视频'
  },
  component: () => import(/* webpackChunkName: "selectCar" */ '@/views/littleVedio/index.vue')
}, {
  path: '/my',
  name: 'my',
  meta: {
    title: '我的'
  },
  component: () => import(/* webpackChunkName: "my" */ '@/views/my/index.vue')
}]


const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'layout',
    component: () => import(/* webpackChunkName: "layout" */ '@/views/layout/index.vue'),
    children: layoutChildren
  },
  {
    path: '/select/car/:id',
    name: 'selectCarDetail',
    component: () => import(/* webpackChunkName: "selectCarDetail" */ '@/views/selectCarDetail/index.vue')
  },
  {
    path: '/posts/:id',
    name: 'posts',
    component: () => import(/* webpackChunkName: "posts" */ '@/views/posts/index.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '@/views/login/index.vue')
  },
  {
    path: '/user/history',
    name: 'userHistory',
    component: () => import(/* webpackChunkName: "userHistory" */ '@/views/userHistory/index.vue')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
